﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Control_UpdateCustomerControl : System.Web.UI.UserControl
{
    ListAndProcessData ws = new ListAndProcessData();
    private string id = null;
    private string getsex = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        id = Request.QueryString["idCustomer"];

        if(!IsPostBack)
        {
            txtFullNameCustomer.Text = Request.QueryString["fullNameCustomer"].ToString();
            txtAge.Text = Request.QueryString["age"].ToString();
            getsex = Request.QueryString["sex"].ToString();
            if (getsex.Equals("Male"))
            {
                DropDownList1.SelectedValue = "Male";
            }
            else
            {
                DropDownList1.SelectedValue = "FeMale";
            }
            txtAddress.Text = Request.QueryString["address"].ToString();
            txtPhone.Text = Request.QueryString["phone"].ToString();
            txtEmail.Text = Request.QueryString["email"].ToString();
            txtCMND.Text = Request.QueryString["identityCard"].ToString();
        }
       
        
    }


    protected void  btnUpdate_Click(object sender, EventArgs e)
    {
        bool a = false;

        if (DropDownList1.SelectedValue == "Male")
        {
            a = ws.UpdateCustomer(id, txtFullNameCustomer.Text, txtAge.Text, 0, txtAddress.Text, txtPhone.Text, txtEmail.Text, txtCMND.Text);
        }
        if (DropDownList1.SelectedValue == "FeMale")
        {
            a = ws.UpdateCustomer(id, txtFullNameCustomer.Text, txtAge.Text, 1, txtAddress.Text, txtPhone.Text, txtEmail.Text, txtCMND.Text);
        }

        
        if (a == true)
        {
            Response.Redirect("Customer_Admin.aspx");

        }
        else
        {
            Response.Redirect("Default3.aspx");
        }
    }
        
    protected void btnreset_Click(object sender, EventArgs e)
    {

    }
}